package com.qing.design.patterns.chain_of_responsibility.example.server;

import com.qing.design.patterns.chain_of_responsibility.example.middleware.Middleware;

public class LoginServer {


	private Middleware middleware;


	public LoginServer() {
	}

	public LoginServer(Middleware middleware) {
		this.middleware = middleware;
	}

	/**
	 * 客户端将对象链传递给服务器。这提高了灵活性和灵活性使测试服务器类更容易。
	 * @param middleware
	 * @return
	 */
	public void setMiddleware(Middleware middleware) {
		this.middleware = middleware;
	}


	public boolean login(String email,String password){
		if(middleware.check(email, password)){
			System.out.println("授权成功！");
			//在这里为授权用户做一些有用的事情。
			return true;
		}
		return  false;
	}

}
